#include "../header.h"


/**
 * @函数原型:  int unlink(const char *pathname);
 * @函数功能:  delete a name and possibly the file it refers to
 * @参数说明: 删除文件
 * @       参数1: pathname 文件名
 * @返回值: 成功返回0 失败返回-1
 * @param {int} argc
 */
/**
 * @函数原型: int remove(const char *pathname);
 * @函数功能: 删除文件或者目录。
 * @参数说明: 
 * @       参数1: 文件路径
 * @返回值: 成功返回0 失败返回-1；
 * On success, zero is returned.  On error, -1 is returned, and errno is set appropriately.
 * @param {int} argc
 */
int main(int argc, char const *argv[])
{
    //命令行参数判断
    if (argc < 3)
    {
        perror("argc error\n");
        return -1;
    }

    //判断文件是否存在
    //! 1 存在判断
    if(!access(argv[1],F_OK))
        printf("this file is exits\n");
    else
    {
        printf("this file is not exits\n");
        return -1;
    }
    //! 2. unlink
    if (!unlink(argv[1]))
        printf("delete this file:%s success\n",argv[1]);
    else
        printf("delete this file : %s error\n",argv[1]);

    //! 3.remove
    if(!remove(argv[2]))
        printf("remove this file:%s success\n",argv[2]);
    else
        printf("delete this file : %s error\n",argv[2]);





    return 0;
}
